<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /* 
    求1 + 2！ + 3！ + 4！....+20!的值
	- 2！ = 2 * 1
	- 3！ = 3 * 2 * 1
    */
   var num = 1 //变量存放每次循环执行后的值，由于该运算是乘法运算--默认值为1
   var sum = 0 //来存放每次阶乘与阶乘之间的和，默认值为0
   for(var i = 1; i <= 20; i++){
       num = num * i
       sum = sum + num
   }
   console.log(sum)
</script>
</html>